package SimpleSelenium.buxfer.po;

import SimpleSelenium.buxfer.tests.BuxferBaseTest;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

/**
 * Created with IntelliJ IDEA.
 * User: dmytro.v.kozlov
 * Date: 7/10/13
 * Time: 11:55 AM
 * To change this template use File | Settings | File Templates.
 */
public class WellcomePage extends BuxferBasePage {

    @FindBy(id="login_username")
    private WebElement loginUsername;
    @FindBy(id="login_password")
    private WebElement loginPassword;
    @FindBy(xpath =".//*[@id='login_form']/div[1]/table/tbody/tr/td[3]/table/tbody/tr[2]/td/div/a" )
    private WebElement loginButton;

    public WellcomePage(WebDriver driver){
        PageFactory.initElements(driver,this);
    }
    public SummaryPage login(String email, String password) {
       loginUsername.sendKeys(email);
       loginPassword.sendKeys(password);
       loginButton.click();

       return new SummaryPage(Browser.driver());
    }
    public boolean isOnPage(){
        return Browser.driver().getTitle().equals("Buxfer: Easy online money management");
    }
}
